package com.xbongbong.saas.enums;

import com.xbongbong.saas.enums.base.KnowledgeDataBaseEnum;
import com.xbongbong.saas.enums.business.*;
import lombok.Getter;

import java.util.Objects;

/**
 * 单行数据代表名称
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/28 14:38
 * @since v1.0
 */
@Getter
public enum RowNameEnum {
    // 列表页批量选择展示名称，以及列表页标识那个字段打开自己的详情
    CUSTOMER_MANAGEMENT(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(),CustomerManagementEnum.NAME.getAttr()),
    CUSTOMER(XbbRefTypeEnum.CUSTOMER.getCode(),CustomerManagementEnum.NAME.getAttr()),
    CUSTOMER_FOCUS(XbbRefTypeEnum.CUSTOMER_FOCUS.getCode(),CustomerManagementEnum.NAME.getAttr()),
    CUSTOMER_DEAL(XbbRefTypeEnum.CUSTOMER_DEAL.getCode(),CustomerManagementEnum.NAME.getAttr()),
    CUSTOMER_FOLLOW(XbbRefTypeEnum.CUSTOMER_FOLLOW.getCode(),CustomerManagementEnum.NAME.getAttr()),
    CUSTOMER_PUBLIC(XbbRefTypeEnum.CUSTOMER_PUBLIC.getCode(),CustomerManagementEnum.NAME.getAttr()),
    CUSTOMER_RECYCLE(XbbRefTypeEnum.CUSTOMER_RECYCLE.getCode(),CustomerManagementEnum.NAME.getAttr()),
    CUSTOMER_NEARBY(XbbRefTypeEnum.CUSTOMER_NEARBY.getCode(),CustomerManagementEnum.NAME.getAttr()),
    CONTRACT(XbbRefTypeEnum.CONTRACT.getCode(),ContractEnum.CONTRACT_NO.getAttr()),
    SALES_OPPORTUNITY(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(),SalesOpportunityEnum.SERIAL_NO.getAttr()),
    ALL_OPPORTUNITY(XbbRefTypeEnum.ALL_OPPORTUNITY.getCode(),SalesOpportunityEnum.SERIAL_NO.getAttr()),
    KEY_OPPORTUNITY(XbbRefTypeEnum.KEY_OPPORTUNITY.getCode(),SalesOpportunityEnum.SERIAL_NO.getAttr()),
    CONTACT(XbbRefTypeEnum.CONTACT.getCode(),ContactEnum.NAME.getAttr()),
    COMMUNICATE_PLAN(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(),CommunicatePlanEnum.NAME.getAttr()),
    PRODUCTION_ORDER(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(),ProductionOrderEnum.SHEET_NO.getAttr()),
    BOM_BILL(XbbRefTypeEnum.BOM_BILL.getCode(),BomBillEnum.SHEET_NO.getAttr()),
    ASSEMBLE(XbbRefTypeEnum.ASSEMBLE.getCode(),AssembleEnum.SHEET_NO.getAttr()),
    PURCHASE(XbbRefTypeEnum.PURCHASE.getCode(),PurchaseEnum.SHEET_NO.getAttr()),
    SUPPLIER(XbbRefTypeEnum.SUPPLIER.getCode(),SupplierEnum.SUPPLIER_NAME.getAttr()),
    SUPPLIER_CONTACT(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(),SupplierContactEnum.NAME.getAttr()),
    PAYMENT(XbbRefTypeEnum.PAYMENT.getCode(),PaymentEnum.PAYMENT_NO.getAttr()),
    PAY_PLAN(XbbRefTypeEnum.PAY_PLAN.getCode(),PayPlanEnum.PAY_PLAN_NO.getAttr()),
    INVOICE(XbbRefTypeEnum.INVOICE.getCode(),InvoiceEnum.SHEET_NO.getAttr()),
    PURCHASE_INVOICE(XbbRefTypeEnum.PURCHASE_INVOICE.getCode(), PurchaseInvoiceEnum.SHEET_NO.getAttr()),
    OTHER_INCOME(XbbRefTypeEnum.OTHER_INCOME.getCode(), OtherIncomeEnum.SHEET_NO.getAttr()),
    OTHER_EXPENSE(XbbRefTypeEnum.OTHER_EXPENSE.getCode(), OtherExpenseEnum.SHEET_NO.getAttr()),
    FUND_TRANSFER(XbbRefTypeEnum.FUND_TRANSFER.getCode(), FundTransferEnum.SHEET_NO.getAttr()),
    INSTOCK(XbbRefTypeEnum.INSTOCK.getCode(),InstockEnum.SHEET_NO.getAttr()),
    PURCHASE_INSTOCK(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), PurchaseInstockEnum.SHEET_NO.getAttr()),
    REFUND_INSTOCK(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), RefundInstockEnum.SHEET_NO.getAttr()),
    OTHER_INSTOCK(XbbRefTypeEnum.OTHER_INSTOCK.getCode(), InstockEnum.SHEET_NO.getAttr()),
    PRODUCTION_INSTOCK(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), ProductionInstockEnum.SHEET_NO.getAttr()),
    RETURNED_MATERIEL_INSTOCK(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), ReturnedMaterielInstockEnum.SHEET_NO.getAttr()),
    OUTSTOCK(XbbRefTypeEnum.OUTSTOCK.getCode(),OutstockEnum.SHEET_NO.getAttr()),
    CONTRACT_OUTSTOCK(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(),ContractOutstockEnum.SHEET_NO.getAttr()),
    RETURNED_PURCHASE_OUTSTOCK(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(),ReturnedPurchaseOutstockEnum.SHEET_NO.getAttr()),
    OTHER_OUTSTOCK(XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(),OutstockEnum.SHEET_NO.getAttr()),
    PRODUCTION_MATERIEL_OUTSTOCK(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(),ProductionMaterielOutstockEnum.SHEET_NO.getAttr()),
    WORK_ORDER_OUTSTOCK(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(),WorkOrderOutstockEnum.SHEET_NO.getAttr()),
    RETURNED_PURCHASE(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(),ReturnedPurchaseEnum.SHEET_NO.getAttr()),
    WAREHOUSE(XbbRefTypeEnum.WAREHOUSE.getCode(),WarehouseEnum.WAREHOUSE_NAME.getAttr()),
    PRODUCT(XbbRefTypeEnum.PRODUCT.getCode(),ProductEnum.NAME.getAttr()),
    TRANSFER(XbbRefTypeEnum.TRANSFER.getCode(),TransferEnum.SHEET_NO.getAttr()),
    INVENTORY(XbbRefTypeEnum.INVENTORY.getCode(),InventoryEnum.SHEET_NO.getAttr()),
    WAIT_OUTSTOCK(XbbRefTypeEnum.WAIT_OUTSTOCK.getCode(),ContractEnum.NAME.getAttr()),
    WAIT_INSTOCK_PURCHASE(XbbRefTypeEnum.WAIT_INSTOCK_PURCHASE.getCode(),PurchaseEnum.SHEET_NO.getAttr()),
    WAIT_PURCHASE(XbbRefTypeEnum.WAIT_PURCHASE.getCode(),ContractEnum.NAME.getAttr()),
    WAIT_PRODUCE(XbbRefTypeEnum.WAIT_PRODUCE.getCode(),ContractEnum.NAME.getAttr()),
    STOCK_SEARCH(XbbRefTypeEnum.STOCK_SEARCH.getCode(), ProductEnum.NAME.getAttr()),
    WARNING_SEARCH(XbbRefTypeEnum.WARNING_SEARCH.getCode(), ProductEnum.NAME.getAttr()),
    GUARANTEE_SEARCH(XbbRefTypeEnum.GUARANTEE_SEARCH.getCode(), ProductEnum.NAME.getAttr()),
    REFUND(XbbRefTypeEnum.REFUND.getCode(), RefundEnum.REFUND_NO.getAttr()),
    WORKORDER(XbbRefTypeEnum.WORK_ORDER.getCode(), WorkOrderEnum.SHEET_NO.getAttr()),
    WORKORDER_ROB(XbbRefTypeEnum.WORK_ORDER_ROB.getCode(), WorkOrderEnum.SHEET_NO.getAttr()),
    QUOTATION(XbbRefTypeEnum.QUOTATION.getCode(), QuotationEnum.QUOTATION_NO.getAttr()),
    PAYMENT_SHEET(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), PaymentSheetEnum.SHEET_NO.getAttr()),
    PREPAYMENT_BALANCE(XbbRefTypeEnum.PREPAYMENT_BALANCE.getCode(), PaymentBalanceEnum.CUSTOMER_NAME.getAttr()),
    PAY_SHEET(XbbRefTypeEnum.PAY_SHEET.getCode(), PaySheetEnum.PAY_PLAN_NO.getAttr()),
    PREPAY_BALANCE(XbbRefTypeEnum.PREPAY_BALANCE.getCode(), PayBalanceEnum.SUPPLIER_NAME.getAttr()),
    ALL_CLUE(XbbRefTypeEnum.ALL_CLUE.getCode(), ClueEnum.COMPANY_NAME.getAttr()),
    CLUE_PUBLIC(XbbRefTypeEnum.CLUE_PUBLIC.getCode(),ClueEnum.COMPANY_NAME.getAttr()),
    CLUE_RECYCLE(XbbRefTypeEnum.CLUE_RECYCLE.getCode(),ClueEnum.COMPANY_NAME.getAttr()),
    MARKET_ACTIVITY(XbbRefTypeEnum.MARKET_ACTIVITY.getCode(), MarketActivityEnum.NAME.getAttr()),

    CREDIT_LIMIT(XbbRefTypeEnum.CREDIT_LIMIT.getCode(), CreditLimitEnum.CREDIT_NO.getAttr()),
    CREDIT_FIXED_LIMIT(XbbRefTypeEnum.CREDIT_FIXED_LIMIT.getCode(), CreditFixedLimitEnum.CREDIT_FIXED_NO.getAttr()),
    CREDIT_TEMPORARY_LIMIT(XbbRefTypeEnum.CREDIT_TEMPORARY_LIMIT.getCode(), CreditTemporaryLimitEnum.CREDIT_TEMPORARY_NO.getAttr()),
    MARKETING_ACTIVITY_MANAGEMENT(XbbRefTypeEnum.MARKETING_ACTIVITY_MANAGEMENT.getCode(), MarketingActivityManagementEnum.NAME.getAttr()),
    PROMOTION_ACTIVITY_MANAGEMENT(XbbRefTypeEnum.PROMOTION_ACTIVITY_MANAGEMENT.getCode(), PromotionActivityManagementEnum.NAME.getAttr()),
    WRITE_OFF_RECORD(XbbRefTypeEnum.WRITE_OFF_RECORD.getCode(), WriteOffRecordEnum.ORDER_NO.getAttr()),
    DISTRIBUTOR_MANAGEMENT(XbbRefTypeEnum.DISTRIBUTOR_MANAGEMENT.getCode(), DistributorEnum.NAME.getAttr()),
    DISTRIBUTOR_CONTACT(XbbRefTypeEnum.DISTRIBUTOR_CONTACT.getCode(), DistributorContactEnum.NAME.getAttr()),
    DISTRIBUTOR_ACCOUNT(XbbRefTypeEnum.DISTRIBUTOR_ACCOUNT.getCode(),  DistributorAccountEnum.NAME.getAttr()),
    ORDER(XbbRefTypeEnum.ORDER.getCode(),  OrderEnum.ORDER_NO.getAttr()),
    RETURN(XbbRefTypeEnum.RETURN.getCode(), ReturnEnum.RETURN_NO.getAttr()),
    COST_ADJUST(XbbRefTypeEnum.COST_ADJUST.getCode(), CostAdjustEnum.ADJUST_NO.getAttr()),
    SMART_REPLENISHMENT(XbbRefTypeEnum.SMART_REPLENISHMENT.getCode(), SmartReplenishmentEnum.PRODUCT_NO.getAttr()),
    KNOWLEDGE_BASE(XbbRefTypeEnum.KNOWLEDGE_BASE.getCode(), KnowledgeDataBaseEnum.TITLE.getAttr()),
    WORK_ORDER_V2(XbbRefTypeEnum.WORK_ORDER_V2.getCode(), WorkOrderEnum.SHEET_NO.getAttr()),
    WORK_ORDER_V2_APPOINT(XbbRefTypeEnum.WORK_ORDER_V2_APPOINT.getCode(), WorkOrderEnum.SHEET_NO.getAttr()),
    WORK_ORDER_V2_POOL(XbbRefTypeEnum.WORK_ORDER_V2_POOL.getCode(), WorkOrderEnum.SHEET_NO.getAttr()),
    SERVICE_PROJECT(XbbRefTypeEnum.SERVICE_PROJECT.getCode(), ServiceProjectEnum.SERIALNO.getAttr()),
    COMPETITOR(XbbRefTypeEnum.COMPETITOR.getCode(),CompetitorEnum.NAME.getAttr()),

    UNKNOW(XbbRefTypeEnum.UNKNOWN.getCode(),""),
    ;
    private Integer businessType;
    private String attr;

    RowNameEnum(Integer businessType, String attr) {
        this.businessType = businessType;
        this.attr = attr;
    }

    public static RowNameEnum getByBusinessType(Integer businessType) {
        if (Objects.isNull(businessType)){
            return UNKNOW;
        }
        for (RowNameEnum cacheCode : values()) {
            if (businessType.equals(cacheCode.getBusinessType())) {
                return cacheCode;
            }
        }
        return UNKNOW;
    }
}
